package com.example.springboottestservice.event;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.stereotype.Component;

@Component
public class EventPublisher {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    public void Publish(){
        applicationEventPublisher.publishEvent(new EventTest("hello"));
    }

    private static class EventTest extends ApplicationEvent {
        private String msg;

        public EventTest(String msg) {
            super(msg);
            this.msg = msg;
        }
    }

}
